/*
 * Authors: Alex Attar & Kevin El Hage
 * ID: 9765727
 * Date: 9/3/2012
 * 
 */

package taskManagerSystem.ViewSubsystem;

import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;

/* The TaskView class inherits all the methods and variables from Table class
 * and sets the width of columns "ID", "Duration" and "Deadline" in the task table to a
 * pre-defined width, and gives focus to the table when the user clicks on the task
 * table.
 */

public class TaskView extends Table {
	
	public TaskView(String[] columnNames, Class<?>[] columnTypes) {
		super(columnNames, columnTypes);
		
		// helps set the cell' text alignment
		DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();  
	    dtcr.setHorizontalAlignment(SwingConstants.LEFT);  
		
		//set focus on the task table
		setSurrendersFocusOnKeystroke(true);
		
		//set the preferred and max widths of column "ID"
		TableColumn idCol = getColumn("ID");
		idCol.setPreferredWidth(35);
		idCol.setMaxWidth(40);
		disableColumn(0); 
	    idCol.setCellRenderer(dtcr);   // align left
		
		
		//set the preferred and max widths of column "Duration"
		TableColumn durCol = getColumn("Duration");
		durCol.setPreferredWidth(60);
		durCol.setMaxWidth(65);
		
		durCol.setCellRenderer(dtcr);	// align left
		
		
		//set the preferred and max widths of column "Deadline"
		TableColumn dlCol = getColumn("Deadline");
		dlCol.setPreferredWidth(65);
		dlCol.setMaxWidth(90);
		dlCol.setMinWidth(65);	
		
		//set the preferred and max widths of column "Parent Task"
		TableColumn parentCol = getColumn("Parent Task");
		parentCol.setPreferredWidth(80);
		parentCol.setMinWidth(80);
		parentCol.setMaxWidth(100);
		parentCol.setCellRenderer(dtcr);   // align left
	}
}
